<?php


/*
 * Created on Dec 3, 2011
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
	$desteid = "dtn://hao.bytewalla.com";

	$mailto = $_POST['mailto'];
	$subject = $_POST['subject'];
	$msg = $_POST['message'];
	
	$data =  $mailto."\n".$subject."\n".$msg;
	
	$filename =  time(). ".mail";
	$fileposition = "/var/www/wsn/mail/" . $filename;

	$f = fopen($fileposition, 'w');
	fwrite($f, $data);
	fclose($f);

	
	include_once ("httpsqs/httpsqs_client.php");
	$httpsqs_host = "localhost";
	$httpsqs_port = "1218";
	$httpsqs_auth = "";
	$httpsqs_charset = "utf-8";
	$httpsqs = new httpsqs($httpsqs_host, $httpsqs_port, $httpsqs_auth, $httpsqs_charset);
			//curl -d "dtncp /home/hao/test.txt dtn://hao.bytewalla.com"  "http://localhost:1218/?charset=utf-8&name=&opt=put"
	$httpsqs->reset("text_java_request");
	$cmd = "dtncp ".$fileposition." ". $desteid;
	$result = $httpsqs->put("text_java_request", $cmd);
	header("Location:dtnmailres.php");
?>
